{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-title">
        <h5>开通会员</h5>
    </div>
    <div class="ibox-content layui-form">
        <div class="layui-row layui-col-space10 layui-form-item ">
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">选择用户：</label>
                <div class="layui-input-block">
                    <select name="user_id" xm-select="select1" lay-verify="required" xm-select-radio=""
                            xm-select-search="" xm-select-search-type="dl" lay-filter="user_id">
                        {foreach name="userLists" item="v"}
                        <option value="{$v.user_id}" >{$v.user_username}</option>
                        {/foreach}
                    </select>
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">会员等级：</label>
                <div class="layui-input-block">
                    <select name="user_auth" lay-verify="required" xm-select-search="">
                        <option value="2" >季度会员</option>
                        <option value="3" >半年会员</option>
                        <option value="4" >一年会员</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">开始时间：</label>
                <div class="layui-input-inline">
                    <input type="text"  name="start" class="layui-input layer-date search test-item" placeholder="开始日期"/>
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                    </button>
                    <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}

<script>
    layui.use(['form','laydate'], function() {
        var form = layui.form;
//        var user_name = '';
        form.on('submit(component-form-element)', function (data) {
//            if(confirm(JSON.stringify(data.field.user_auth))){
//            user_name = layui.formSelects.value('select1');
//            console.log(user_name[0].name);
            if(confirm('确认开通会员吗？')){
                $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
                $.ajax({
                    url:"{:url('addMember')}",
                    type:'post',
                    dataType:'json',
                    data:data.field,
                    success:function(res){
                        if (res.code == 200) {
                            wk.success(res.msg,"{:url('Membership/index')}")
                        } else {
                            wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\')');
                        }
                    }
                })
            }
        });
        var laydate = layui.laydate;
        //同时绑定多个
        lay('.test-item').each(function(){
            laydate.render({
                elem: this
                ,format:'yyyy-MM-dd HH:mm:ss'
                ,type:'datetime'
                ,trigger: 'click'
            });
        });
    });
</script>
</body>
</html>